// cmath Demo
// Created by Administrator on 2025/6/26.
//

#include <cmath>
#include <iostream>
using namespace std;


void demo1() {
    cout << "绝对值：\t" << abs(-5) << endl;
    cout << "浮点数绝对值：\t" << fabs(-15.5f) << endl;
    cout << "5.5 / 2 的余数为：\t" << fmod(5.5f, 2) << endl;
    cout << "5.5 / 2 的商为：\t" << trunc(5.5f / 2) << endl;
    cout << "5.5 / 2 的余数为：\t" << remainder(5.5f, 2) << endl;
    cout << "20 和 10 谁更大？\t" << fmax(20, 10) << endl;
    cout << "20 和 10 谁更小？\t" << fmin(20, 10) << endl;
    cout << endl;
    cout << "不小于 2.6 的整数：\t" << ceil(2.6) << endl;
    cout << "不大于 5.8 的整数：\t" << floor(5.8) << endl;
    cout << "去除小数的 10.8 的值：\t" << trunc(10.8) << endl;
    cout << "四舍五入的值：\t" << round(55.5f) << endl;

    if (isinf(1.0f / 0.0f)) {
        cout << "1.0f / 0.0f 无穷大" << endl;
    }
}

int main(int argc, char *argv[]) {
    demo1();
}
